
package com.phpxiu.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout.LayoutParams;


import com.phpxiu.app.model.list.ListItem;

import java.util.ArrayList;
import java.util.List;


public abstract class BaseSwipeListViewAdapter<T extends ListItem> extends BaseAdapter {
    protected Context context;
    protected List<T> data=new ArrayList<T>();
    protected LayoutInflater mInflater;
    /**
     * 右边视图宽度
     */
    protected int mRightWidth = 0;

    /**
     * 单击事件监听器
     */
    protected IOnItemRightClickListener mListener = null;

    protected LayoutParams leftParam,rightParam;
    public BaseSwipeListViewAdapter(Context context, List<T> data,int mRightWidth, IOnItemRightClickListener mListener) {
        this.context = context;
        this.data = data;
        mInflater=LayoutInflater.from(context);
        this.mRightWidth = mRightWidth;
        leftParam=new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        rightParam=new LayoutParams(mRightWidth, ViewGroup.LayoutParams.MATCH_PARENT);
        this.mListener = mListener;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public interface IOnItemRightClickListener extends View.OnClickListener {
        void onRightClick(View v, int position);
    }
}
